/**	@author Nguyen Hua Phung,PhD
 *	@version 1.1
 */
package MP.staticchecker;

import MP.lexicalanalysis.Token;

public class SymEntry {
	public static final int GLOBAL = 0;
	public static final int PROC = 1;
	public static final int BLOCK = 2;
	
	private Token id;
	private Type type;
	private String value;
	private int scope;
	private Object object;
	
	/** create an instance of SymEntry
	 * @param id token id
	 * @param type the type of token id
	 */
	public SymEntry(Token id,Type type) { 
		this.id = id;
		this.type = type;
		value = null;
	}
	/** create an instance of SymEntry
	 * @param id token id
	 * @param type the type of token id
	 * @param s the lexeme of constant
	 */
	public SymEntry(Token id,Type type, String s) { 
		this.id = id;
		this.type = type;
		value = s;
	}

	/** return the lexeme of this entry
	 *	@return lexeme the lexeme of the entry
	 */
	public String getLexeme() {
		return id.Lexeme;
	}
	
	/** return the type of this entry
	 *	@return type the type of the entry
	 */
	public Type getType() {
		return type;
	}
	
	/** set type to this entry
	 *	@param t the type of the entry
	 */
	public void setType(Type t) {
		type = t;
	}
	/** return the id of this entry
	 * 	@return token token id of the entry
	 */
	public Token getId() {
		return id;
	}

	/** return the lexeme of the constant
	 * 	@return value the lexeme of the constant
	 */
	public String getValue() {
		return value;
	}

	/** convert to String
	 *	@return string the corresponding string of the entry
	 */
	public String toString() {
		//return id.Lexeme+" "+type.toString()+" "+scope+" "+object.toString();
		return id.Lexeme+" "+type.toString()+" "+" "+object.toString();
	}
	/** set the scope of the entry
	 *	@param b the scope of the entry
	 *
	 */
	public void setScope(int s) {
		this.scope = s;
	}
	 
	/** get the scope of the entry
	 *	@return the scope of the entry
	 */
	public int getScope() {
	 	return this.scope;
	}

	/** set the object to this entry
	 * @param object the object of this entry.<p>
	 *	object is an index if the entry is of a block variable.<p>
	 *		   is the class name if the entry is of a method.<p>	
	 */
	public void setObject(Object object) {
	 	this.object = object;
	}	
	   	
	/** get the object of this entry
	 *	@return object the object of this entry
	 */
	public Object getObject() {
	 	return object;
	}
	
}
